#include "RPN.h"
#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;

int main(int argc, char** argv) {
    printf( "CALCULATOR. Created by Shemyakin Roman. Tested on Mac OS X Lion.\n"
            "Compiler: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)\n\n"
            "Insert your sentense according the following rules:\n"
            "1.You can use real values in your calculations. Notice, that it will work like 'double' type in C/C++.\n"
            "2.You can use algebraic operators: + , - , * , / , ^\n"
            "  They are binary, so you must put two constants around them.\n"
            "3.You can use unary minus everywhere but not after '(...)' & constants :\n"
            "  Unary: '12+-1' ~ '12-1'; '-(123-126)' ~ '3'; 'e^-1' ~ '1/e' etc.\n"
            "  Binary: '(12+6)-10' ~ '8'; 'e-10'\n"
            "4.You can use 'sin' & 'cos' functions. They'll be working like standart math.h functions.\n"
            "5.You can divide parts of your sentence by different scobes: (,),[,],{,}. It seems to be useful.\n"
            "6.To stop the calculation iterations type 'quit'!!!\n\n"
            ); // Инструкция.
    while(1){
        try{
            cout << "Sent.: ";
            char s[105];
            //gets(s); - небезопасна((
            cin.getline(s,102);
            RPN expression(s);            
            expression.print();
        }
        catch(const char * str){ // Ловим ошибки.
            cout << str << endl; 
        }
        catch(int){ // Выход.
            return 0;
        }
    }
}

